import kotlin.math.roundToInt

fun main() {

    //val number1: Int = "8.98".toInt()
    //安全转换函数，异常就返回null
    val number1: Int? = "8.98".toIntOrNull()
    println(number1)

    println(8.956756.toInt())//精度损失
    println(8.956756.roundToInt())//四舍五入

    val s = "%.2f".format(8.956756)//保留两位
    println(s)
}